<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<title>日报</title>
		<link rel="stylesheet" href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
.ui-datalist-empty-message {
	/* height: 100px; */
	min-height: 100px;
}

.ui-datalist-content {
	/* height: 100px; */
	min-height: 100px;
}

.purple {
	background-color: #fafbc0;
}

.green {
	background-color: #d7f1f9;
}

.red {
	background-color: #c2e4a3;
}
</style>
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div id="headDiv" class="box box-solid with-border">
			<h:form id="headForm">
				<div class="box-header" id="queryDiv">
					<p:growl id="msgs" showDetail="true" />
					<p:outputLabel value="检修状态：" />
					<h:selectOneMenu id="queryTxt" value="#{overhaulmagController.queryTxt}"
						style="width:130px;margin-right:20px;height:30px">
						<f:selectItem itemLabel="全部" itemValue="全部" />
						<f:selectItem itemLabel="待开工" itemValue="待开工" />
						<f:selectItem itemLabel="进行中" itemValue="进行中" />
						<f:selectItem itemLabel="已完工" itemValue="已完工" />
						<p:ajax event="change" oncomplete="getTableScrollHeight();"
							listener="#{overhaulmagController.queryByTimeAndState()}" update="form:dataTb" />
					</h:selectOneMenu>
					<p:outputLabel for="popup1" value="结束时间：" />
					<p:calendar id="popup1" navigator="true" value="#{overhaulmagController.queryDate1}"
						pattern="yyyy-MM-dd">
					</p:calendar>
					<p:outputLabel for="popup2" value="至" style="margin-right:5px;margin-left:5px;" />
					<p:calendar id="popup2" navigator="true" value="#{overhaulmagController.queryDate2}"
						pattern="yyyy-MM-dd">
					</p:calendar>
					<p:commandButton icon="ui-icon-search" value="查询" update="form:dataTb btnBar"
						actionListener="#{overhaulmagController.queryByTimeAndState()}" style="margin-left:5px;"
						oncomplete="getTableScrollHeight();">
					</p:commandButton>
					<p:commandButton icon="ui-icon-refresh" value="重置"
						actionListener="#{overhaulmagController.resetQuery}" style="margin-left:5px;"
						oncomplete="getTableScrollHeight();" update="queryTxt popup1 popup2 form:dataTb btnBar" />
				</div>
				<div id="toolbarDiv">
					<p:toolbar id="btnBar">
						<f:facet name="left">
							<p:commandButton id="cgBtn1" value="新建" icon="ui-icon-document" update="form:dataTb "
								oncomplete="getTableScrollHeight();" actionListener="#{overhaulmagController.create}"
								rendered="#{s:hasPermission(session,'bhyx_bhrb_bhjxgl_xj')}" />
							<p:commandButton value="删除" id="delbtn1" icon="ui-icon-trash"
								update="form:dataTb msgs btnBar" actionListener="#{overhaulmagController.deleteOverhaul}"
								disabled="#{overhaulmagController.selectOverhaul == null}"
								rendered="#{s:hasPermission(session,'bhyx_bhrb_bhjxgl_sc')}"
								oncomplete="getTableScrollHeight();">
								<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
							</p:commandButton>
						</f:facet>
					</p:toolbar>
				</div>
			</h:form>
		</div>
		<div id="infoDiv" class="box box-solid with-border">
			<h:form id="form">
				<p:dataTable id="dataTb" var="item" value="#{overhaulmagController.overhaul}"
					selection="#{overhaulmagController.selectOverhaul}" rowKey="#{item.id}" emptyMessage="无记录"
					rowStyleClass="#{item.done eq '已完工'  ?'red':(item.done eq '进行中'  ?'green':'purple')}"
					editable="true" paginator="true" rows="20" rowIndexVar="ite"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					paginatorPosition="bottom" scrollable="true">
					<f:facet name="{Customization}">
						<p:outputLabel value="总计：#{overhaulmagController.overhaul.size()} 条记录"
							style="margin-right:20px;"></p:outputLabel>
					</f:facet>
					<p:ajax event="rowSelectRadio" listener="#{overhaulmagController.onRowSelect}"
						update="headForm:btnBar" />
					<p:ajax event="rowEdit" listener="#{overhaulmagController.onRowEdit}"
						update="headForm:msgs form:dataTb" />
					<p:column selectionMode="single" width="10" style="text-align:center" />
					<p:column width="10" headerText="序号 ">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column width="60" headerText="申请单位 ">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.applicantCompany}" />
							</f:facet>
							<f:facet name="input">
								<p:autoComplete value="#{item.applicantCompany}"
									completeMethod="#{substationCompelteController.completeApplicantCompany}"
									scrollHeight="400" dropdown="false">
								</p:autoComplete>
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column width="50" headerText="工作地点">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.station_name}" />
							</f:facet>
							<f:facet name="input">
								<p:autoComplete forceSelection="false" scrollHeight="450" dropdown="true"
									value="#{item.station_name}"
									completeMethod="#{substationCompelteController.completeWorkplace}">
								</p:autoComplete>
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column width="40" headerText="检修状态 ">
						<p:outputLabel value="#{item.done}" style="width:96%" />
					</p:column>
					<p:column width="80" headerText="检修内容">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.content}" style="white-space:pre-wrap;" />
							</f:facet>
							<f:facet name="input">
								<p:inputTextarea rows="5" style="width:100%" label="content" autoResize="false"
									value="#{item.content}"></p:inputTextarea>
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column width="50" headerText="开工时间">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.startTime}">
									<f:convertDateTime pattern="yyyy-MM-dd" />
								</h:outputText>
							</f:facet>
							<f:facet name="input">
								<p:calendar value="#{item.startTime}" navigator="true" pattern="yyyy-MM-dd" />
							</f:facet>
						</p:cellEditor>

					</p:column>
					<p:column width="50" headerText="结束时间">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.endTime}">
									<f:convertDateTime pattern="yyyy-MM-dd" />
								</h:outputText>
							</f:facet>
							<f:facet name="input">
								<p:calendar value="#{item.endTime}" navigator="true" pattern="yyyy-MM-dd" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column width="60" headerText="执行情况">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{item.executiveCondition}" />
							</f:facet>
							<f:facet name="input">
								<p:inputText value="#{item.executiveCondition}" style="width:96%" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column style="width:20px">
						<p:rowEditor />
					</p:column>
				</p:dataTable>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/js/tables/singleScrollTable.js" />
	</ui:define>
</ui:composition>